package com.laima.basic.controller;


import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.laima.basic.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import org.springframework.web.bind.annotation.RestController;


/**
* <p>
* 角色信息表 前端控制器
* </p>
*
* @author py
* @since 2021-01-19
* @version v1.0
*/
@Api(tags = {"角色信息表"})
@RestController
@RequestMapping("sys-role")
public class SysRoleController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private SysRoleService ysRoleService;


    /**
    * 新增数据
    *
    * @param sysRole
    * @return
    */
    @ApiOperation(value = "新增数据", notes = "新增一条角色信息表数据")
    @PostMapping("insert")
    public Long insert(@RequestBody SysRoleVO sysRole) {
        return ysRoleService.insert(sysRole);
    }

    /**
    * 修改数据
    *
    * @param sysRole
    * @return
    */
    @ApiOperation(value = "修改数据", notes = "根据id修改角色信息表数据")
    @PostMapping("update")
    public int update(@RequestBody SysRoleVO sysRole) {
        return ysRoleService.update(sysRole);
    }

    /**
    * 删除数据
    *
    * @param ids
    * @return
    */
    @ApiOperation(value = "删除数据", notes = "根据id删除角色信息表数据")
    @PostMapping("delete")
    public int delete(@RequestBody Long[] ids) {
        return ysRoleService.deleteLogicByIds(ids);
    }

    /**
    * 根据ID查询数据
    *
    * @param id
    * @return
    */
    @ApiOperation(value = "根据ID查询数据", notes = "根据ID查询角色信息表数据")
    @GetMapping("detail")
    public SysRoleDTO detail(@RequestParam("id") Long id) {
        return ysRoleService.getDtoById(id);
    }

    /**
    * 查询分页数据
    */
    @ApiOperation(value = "查询角色信息表分页数据")
    @GetMapping(value = "list")
    public Pagination<SysRoleDTO> list(RequestPage requestPage,Long ownerId){
        return ysRoleService.query(requestPage,ownerId);
    }
}
